home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
emulator
/
bsvc-1.000
/
bsvc-1
/
bsvc-1.0.4
/
samples
/
Hector1600
/
SignedMult.asm
< prev
next >
Wrap
Assembly Source File
|
1995-07-26
|
2KB
|
101 lines
;-----------------------------------------------------------------------------
; ECE463 Signed Multiply
;
; Coded by: Bradford W. Mott
; September 5,1993
;-----------------------------------------------------------------------------
.org 0000
move #512,sp
move #0,r0 ; Init Loop Variable
loop: cmp #num_els,r0 ; Check to see if we're finished
bra finished,.eq
move [r0,data1],r8 ; Get the multiplicand
move [r0,data2],r9 ; Get the multiplier
jsr multiply ; multiply the two numbers
move r0,r1
add r1,r1
move r11,[r1,result] ; Store the result
move r10,[r1,result+1]
inc r0
bra loop
finished: stop
multiply: clr r10 ; loProd
clr r11 ; hiProd
move #15,r12 ; Init the counter
mloop: shr r9 ; Shift the multiplier by one bit
bra noadd,.cc ; Was the bit a 0 or a 1?
clc
addc r8,r11 ; hiProd:=BaddV(hiProd,mcnd,0,V)
bra m1,.t
noadd: add #0,r12 ; clear V flag
m1: bra flip1,.vs
clc
btst #0x8000,r11
bra m2,.eq
sec
bra m2,.t
flip1: clc
btst #0x8000,r11
bra m2,.ne
sec
m2: ror r11 ; hiProd := Bshr(hiProd,sign,C)
ror r10 ; loProd := Bshr(loProd,C,C)
dec r12
bra mloop,.ne
shr r9
bra noadd2,.cc
not r8
sec
addc r8,r11 ; hiProd := BaddV(hiPord,Bcom(mcnd),1,V)
bra z1
noadd2: add #0,r12
z1: bra flip2,.vs
clc
btst #0x8000,r11
bra z2,.eq
sec
bra z2,.t
flip2: clc
btst #0x8000,r11
bra z2,.ne
sec
z2: ror r11 ; hiProd := Bshr(hiProd,sign,C)
ror r10 ; loProd := Bshr(loProd,C,C)
rts ; That's All
.org 256
num_els: .equ 4
data1: .word 0x0005,0x000A,0x00FF,0xFFFF
data2: .word 0x0005,0x0000,0xFFFF,0xFFFF
result: .rmw num_els+num_els